package com.xiaotao.xiaotaorpc.server;

import io.vertx.core.Vertx;

public class VertxHttpServer implements HttpServer {
    @Override
    public void doStart(int port) {
        // 创建 Vert.x 实例
        Vertx vertx = Vertx.vertx();

        // 创建 Http 服务器
        io.vertx.core.http.HttpServer server = vertx.createHttpServer();

        // 监听端口并处理请求
        server.requestHandler(request -> {
            // 处理 Http 请求
            System.out.println("Received request: " + request.method() + " " + request.uri());

            // 发送 http 响应
            request.response().
                    putHeader("content-type", "text/plain").
                    end("Hello from Vert.x Http Server!");
        });
    }
}
